/*
 * @Author: GL
 * @LastEditTime: 2021-05-13 11:09:13
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 */
import axios from './request'
import { api } from './api.config'

// 获取用户信息
export const getUserInfo = () => {
  return axios.post(api.user.findUserInfo)
}

// 实名认证
export const auditeUserRealName = (data) => {
  return axios.post(api.user.auditeUserRealName, data)
}

// 获取我的橱窗列表
export const getMyShopList = (pageNum = 0, pageSize = 10) => {
  return axios.post(api.shop.getMyShopList, { pageNum, pageSize })
}

// 获取用户橱窗分类
export const getUserProductCategoryList = (sellerUserId) => {
  return axios.post(api.shop.getUserProductCategoryList, { sellerUserId })
}

// 获取用户橱窗列表
/**
 * @param {*} pageNum 0
 * @param {*} pageSize 10
 * @param {*} categoryId
 * @param {*} sellerUserId
 */
export const getUserShopListByCategoryId = (data) => {
  return axios.post(api.shop.getUserShopListByCategoryId, data)
}

// 开通橱窗
export const saveMyShopStatus = (data) => {
  return axios.post(api.shop.saveMyShopStatus, data)
}

// 获取橱窗产品
export const getProductDetail = (data) => {
  return axios.post(api.shop.getProductDetail, data)
}

// 用户收藏
export const postFaveriate = (action, data) => {
  const url = {
    find: api.user.findFaveriateByPage,
    save: api.user.saveUserFaveriate,
    dislike: api.user.dislikeUserFaveriate
  }
  data.objectType = 'product'
  return axios.post(url[action], data)
}

// 获取我的橱窗列表
export const getMyShopListByCategoryId = (data) => {
  return axios.post(api.shop.getMyShopListByCategoryId, data)
}

// 获取系统商品推荐列表
export const getRecommendProductList = () => {
  return axios.post(api.shop.getRecommendProductList)
}

// 获取系统商品分类标签列表
export const getSYSCategoryList = () => {
  return axios.post(api.shop.getSYSCategoryList)
}

// 获取系统商品列表
export const getProductListBySYSCategory = (data) => {
  data.pageSize = 5
  return axios.post(api.shop.getProductListBySYSCategory, data)
}

// 获取我的收藏的商品列表
export const getMyFavoriteProList = (data) => {
  data.pageSize = 5
  return axios.post(api.shop.getMyFavoriteProList, data)
}

// 商品搜索
export const searchProduct = (data) => {
  data.pageSize = 5
  return axios.post(api.shop.searchProduct, data)
}

// 添加商品到橱窗
export const addProductToMyShop = (data) => {
  return axios.post(api.shop.addProductToMyShop, data)
}

// 添加商品到橱窗
export const delProductInMyShop = (data) => {
  return axios.post(api.shop.delProductInMyShop, data)
}

// 新增分类
export const addMyShopCategory = (data) => {
  return axios.post(api.shop.addMyShopCategory, data)
}

// 删除分类
export const delUserShopCategory = (categoryId) => {
  return axios.post(api.shop.delUserShopCategory, { categoryId })
}

// 排序分类
export const sortMyShopCategory = (categoryIds) => {
  return axios.post(api.shop.sortMyShopCategory, { categoryIds })
}

// 多个商品加入某个分类
export const multiProductInMyCategory = (data) => {
  return axios.post(api.shop.multiProductInMyCategory, data)
}

export default {
  test () {
    return axios.post(api.test)
  }
}
